<script setup>
import { ref } from 'vue';

const props = defineProps(["value"]);
const v = props.value;

const bg = ref("");
if(v.status === 1){
  bg.value = "";
}else{
  bg.value = "https://t7.baidu.com/it/u=1951548898,3927145&fm=193&f=GIF";
}
</script>

<template>
  <div class="answer" :style="{background: `url(${bg})`}">
    <h2>
      <img :src="v.avatar" alt="">
      <span>{{ v.nickname }}</span>
      <em v-if="v.status!==1">已采纳</em>
      <i>{{ v.created_at }}</i>
    </h2>
    <p>
      {{ v.content }}
    </p>
    <p>
      本答案由 <span>{{ v.nickname }}</span> 提供
    </p>
  </div>
</template>

<style>
.answer{
  border: solid 1px #ccc;
  padding: 4px;
  margin: 4px;
}
.answer h2 i{
  font-size: 12px;
  color: #ccc;
  font-weight: normal;
  float: right;
}
.answer img{
  width:30px
}
</style>